<?php

namespace app\admin\model;

use think\Model;

/**
 * 社群资源图
 * @package app\admin\model
 */
class ResourcePath extends Model
{
    /**
     * 社群封面
     * @param $where
     * @return mixed
     */
    public static function findResourcePathValue($where)
    {
        return self::where($where)->value('path');
    }

    /**
     * 社群资源
     * @param $where
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getResourcePath($where)
    {
        $data = self::where($where)->where('type', 1)->hidden(['create_time'])->select();
        return $data ? $data->toArray() : [];
    }

    /**
     * 创建社群封面
     * @param $data
     * @return ResourcePath|Model
     */
    public static function createResourcePath($data)
    {
        return self::create($data);
    }

    /**
     * 删除社群封面
     * @param $where
     * @return bool
     */
    public static function delResourcePath($where)
    {
        return self::where($where)->delete();
    }
}